﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Jack.IData
{
    //@ jack mark 字段标示
    [AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
    public class PropertyAttribute : Attribute
    {
        private string dbColumnName;
        private bool isPrimary;
        private DbType dbType;
        private object defaultValue;
        private bool isIdentify;
        private int length;

        public string DbColumnName
        {
            get;
            set;
        }

        public bool IsPrimary
        {
            get;
            set;
        }
        public bool IsIdentify
        {
            get;
            set;
        }

        public DbType DbType
        {
            get;
            set;
        }
        public object DefaultValue
        {
            get;
            set;
        }
        public int DbLength
        {
            get;
            set;
        }

        public PropertyAttribute(string dbName, bool isPrimery, DbType type, object dValue)
        {
            this.dbColumnName = dbName;
            this.isPrimary = isPrimery;
            this.dbType = type;
            this.defaultValue = this.GetDefaultValue();
        }

        private object GetDefaultValue()
        {
            return new object();
        }

        public PropertyAttribute(string dbName)
        {
            this.dbColumnName = dbName;
            this.isPrimary = false;
            this.dbType = DbType.String;
            this.defaultValue = this.GetDefaultValue();
        }

        public PropertyAttribute(string dbName, bool isPrimery)
        {
            this.dbColumnName = dbName;
            this.isPrimary = isPrimery;
            this.dbType = DbType.String;
            this.defaultValue = this.GetDefaultValue();
        }

        public PropertyAttribute(string dbName, bool isPrimery, DbType type)
        {
            this.dbColumnName = dbName;
            this.isPrimary = isPrimery;
            this.dbType = type;
            this.defaultValue = null;

        }
    }
}
